import {
	defineStore
} from 'pinia';
export const useLoginStore = defineStore('login', {
	state: () => {
		return {
			status: false,
			token: false,
			userInfo: uni.getStorageSync('userinfo') || {}
		};
	},
	// 也可以这样定义
	// state: () => ({ count: 0 })
	getters: {

	},
	actions: {
		getUserInfo(payload) {
			console.log('this', this);
			console.log('payload', payload);
			this.status = payload.status;
			this.token = payload.token;
			this.userInfo = payload
			uni.setStorageSync('userinfo', payload);
			uni.setStorageSync('token', payload.token);
		},
		removeUserInfo() {
			uni.removeStorageSync('userinfo');
			uni.removeStorageSync('token');
			this.status = 0;
			this.token = false;
			this.userInfo = {};
		}
	},
});